package cz.cvut.fit.crhonjar.mi.paa.thames.solver;

import java.util.List;

import cz.cvut.fit.crhonjar.mi.paa.thames.Configuration;
import cz.cvut.fit.crhonjar.mi.paa.thames.Item;
import cz.cvut.fit.crhonjar.mi.paa.thames.exception.ThamesException;

/**
 * 
 * @author Jarec
 * 
 */
abstract public class Solver {

	protected Integer capacity;
	protected Boolean initiated = Boolean.FALSE;

	protected List<Item> items;

	/**
	 * @return
	 */
	public String getName() {
		return this.getClass().getSimpleName();
	}

	/**
	 * @param items
	 * @param bagCapacity
	 */
	public void initiate(final List<Item> items, final Integer bagCapacity) {
		if (items == null) {
			throw new IllegalArgumentException(
					"Solver cannot be initiated with NULL items as parameter!");
		}
		if ((bagCapacity == null)) {
			throw new IllegalArgumentException(
					"Solver cannot be initiated with non-valid capacity! bagCapacity is null");
		}
		this.items = items;
		this.capacity = bagCapacity;
		this.initiated = Boolean.TRUE;
	}

	/**
	 * @return the initiated
	 */
	public Boolean isInitiated() {
		return this.initiated;
	}

	/**
	 * @return
	 * @throws ThamesException
	 * @throws CloneNotSupportedException
	 */
	abstract public Configuration solve() throws ThamesException,
			CloneNotSupportedException;

}
